package com.example.gdzd_demo.exam;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@SpringBootTest
public class match {

    @Test
    public void test() {
        List<Character> teamA = Arrays.asList('a', 'b', 'c');
        List<Character> teamB = Arrays.asList('x', 'y', 'z');

        // 打乱队伍顺序
        Collections.shuffle(teamA);
        Collections.shuffle(teamB);

        // 输出比赛名单
        System.out.println("比赛名单：");
        for (int i = 0; i < 3; i++) {
            System.out.println("甲队：" + teamA.get(i) + " vs 乙队：" + teamB.get(i));
        }
    }


    @Test
    public void test2() {

        char[] teamA = {'a', 'b', 'c'};
        char[] teamB = {'x', 'y', 'z'};

        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (teamA[i] == 'a' && teamB[j] == 'x') {
                    continue; // a不跟x比，跳过这次循环
                } else if (teamA[i] == 'c' && (teamB[j] == 'x' || teamB[j] == 'z')) {
                    continue; // c不跟x,z比，跳过这次循环
                }
                System.out.println("甲队：" + teamA[i] + " vs 乙队：" + teamB[j]);
            }
        }

    }
}
